package com.yhd.enums;

import org.apache.commons.lang3.StringUtils;

public enum TradeStateEnum {
    SUCCESS("SUCCESS", "支付成功"),
    REFUND("REFUND", "转入退款"),
    NOT_PAY("NOTPAY", "未支付"),
    CLOSED("CLOSED", "已关闭"),
    REVOKED("REVOKED", "已撤销（付款码支付）"),
    USER_PAYING("USERPAYING", "用户支付中（付款码支付）"),
    PAY_ERROR("PAYERROR", "支付失败(其他原因，如银行返回失败)");

    private final String code;
    private final String desc;

    TradeStateEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    private static String getDescByCode(String code){
        String desc = StringUtils.EMPTY;
        for (TradeStateEnum e : TradeStateEnum.values()) {
            if (e.getCode().equals(code)){
                desc = e.getDesc();
                break;
            }
        }
        return desc;
    }
}
